import { Router } from 'express'
import { getPool } from '../db.js'

const router = Router()

router.get('/characters', async (req, res) => {
  try {
    const pool = getPool()
    const [rows] = await pool.query('SELECT * FROM characters')
    res.json({ code: 0, data: rows, msg: 'ok' })
    
  } catch (err) {
    console.error('GET /characters error:', err)
    res.status(500).json({ code: 1, msg: 'server error' })
  }
})
export default router
